import { request } from "@/utils/service"
import type * as Combo from "./types/combo"
import { getToken } from "@/utils/cache/cookies"
/** 增 */
export function createComboDataApi(data: any) {
  return request({
    url: "order/package/add",
    method: "post",
    data
  })
}

/** 删 */
export function deleteComboDataApi(id: string) {
  return request({
    url: "order/package/del",
    method: "delete",
    params: {
      id
    }
  })
}

/** 改 */
export function updateComboDataApi(data: any) {
  return request({
    url: "order/package/update",
    method: "put",
    data
  })
}

/** 查 */
export function getComboDataApi(params: Combo.IGetComboRequestData) {
  return request<Combo.GetComboResponseData>({
    url: "order/package/query",
    method: "get",
    params
  })
}

/** 查 去除富文本字段 */
export function getComboDataApi1(params: any) {
  return request<Combo.GetComboResponseData>({
    url: "order/package/queryByName",
    method: "get",
    params
  })
}
/** 查套餐，只保留Id 名字 状态*/
export function getComboDataApi10(params: any) {
  return request<Combo.GetComboResponseData>({
    url: "/order/package/queryPackNameList",
    method: "get",
    params
  })
}

//查询即将下架套餐
export function getWillOffComboDataApi(params: Combo.IGetComboRequestData) {
  return request<Combo.GetComboResponseData>({
    url: "order/package/queryPageWillOverdue",
    method: "get",
    params
  })
}

/**图片上传 */
export function uploadComboImageList(data: any) {
  return request({
    url: "order/package/upload",
    method: "post",
    headers: {
      "Content-Type": "multipart/form-data",
      token: getToken()
    },
    data
  })
}

/** 根据H5套餐/产品id查询详情 */
export function getComboDetail(data: any) {
  return request<any>({
    url: "order/packageBackup/api/queryId",
    method: "post",
    headers: {
      "Content-Type": "multipart/form-data"
    },
    data
  })
}

/** 查询全部分销商*/
export function getUserIdList(params: any) {
  return request({
    url: "/retail/user/queryUserAll",
    method: "get",
    params
  })
}
/** 查询一级分销商*/
export function getUserIdListSub(params: any) {
  return request({
    url: "/retail/user/queryStairUserAll",
    method: "get",
    params
  })
}
//套餐合集相关
/** 增 */
export function createCompailationDataApi(data: any) {
  return request({
    url: "/order/packageHeJi/add",
    method: "post",
    data
  })
}

/** 删 */
export function deleteCompailationDataApi(id: string) {
  return request({
    url: "/order/packageHeJi/del",
    method: "DELETE",
    params: {
      id
    }
  })
}

/** 改 */
export function updateCompailationDataApi(data: any) {
  return request({
    url: "/order/packageHeJi/update",
    method: "put",
    data
  })
}

/** 查 */
export function getCompailationDataApi(params: any) {
  return request({
    url: "/order/packageHeJi/query",
    method: "get",
    params
  })
}
//合集子套餐
/** 增 */
export function createCompilationChildApi(data: any) {
  return request({
    url: "/order/packageHeJiInfo/add",
    method: "post",
    data
  })
}

/** 删 */
export function deleteCompilationChildApi(id: string) {
  return request({
    url: "/order/packageHeJiInfo/del",
    method: "DELETE",
    params: {
      id
    }
  })
}

/** 改 */
export function updateCompilationChildApi(data: any) {
  return request({
    url: "/order/packageHeJiInfo/update",
    method: "put",
    data
  })
}

/** 查 */
export function getCompilationChildApi(params: any) {
  return request({
    url: "/order/packageHeJiInfo/query",
    method: "get",
    params
  })
}
/** 资源ID生成 */
export function createZyID(data: any) {
  return request({
    url: "/order/source/getSourceId",
    method: "post",
    headers: {
      "Content-Type": "multipart/form-data",
      token: getToken()
    },
    data
  })
}

/**一键复制套餐 */
export function copyCombo(id: any) {
  return request<any>({
    url: `/order/package/copyPackage/${id}`,
    method: "get"
  })
}
/**省内省外占比 */
export function province(params: any) {
  return request<any>({
    url: `/order/limit/query`,
    method: "get",
    params
  })
}
/**省内外占比修改 */
export function provinceEdit(data: any) {
  return request({
    url: "/order/limit/updateNums",
    method: "post",
    data
  })
}
